/**
 * 
 */
package com.sci.web.action.datareportseason.enterprise_patent;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import com.sci.web.action.util.BaseAction;
import com.sci.web.bean.Enterprise_Patent;
import com.sci.web.bean.User;
import com.sci.web.dao.DataReportM_InnovateBaseDao;

/**
 * @author BaiFuyou
 * @date: Nov 10, 2011 11:15:21 AM
 * 
 * 增加一条数据
 */
public class AddNewEnterprisePatentAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 685847376737757236L;
	@Resource
	private DataReportM_InnovateBaseDao dataReportM_InnovateBaseDao;
	private int userId;
	private int research_count;
	private int thousand_count;
	private int invent_count;
	private int practical_count;
	private int profile_count;
	private int others_count;
	private int type;
	private String year;

	/**
	 * @return the userId
	 */
	public int getUserId() {
		return userId;
	}

	/**
	 * @param userId
	 *            the userId to set
	 */
	public void setUserId(int userId) {
		this.userId = userId;
	}

	/**
	 * @return the research_count
	 */
	public int getResearch_count() {
		return research_count;
	}

	/**
	 * @param research_count
	 *            the research_count to set
	 */
	public void setResearch_count(int research_count) {
		this.research_count = research_count;
	}

	/**
	 * @return the thousand_count
	 */
	public int getThousand_count() {
		return thousand_count;
	}

	/**
	 * @param thousand_count
	 *            the thousand_count to set
	 */
	public void setThousand_count(int thousand_count) {
		this.thousand_count = thousand_count;
	}

	/**
	 * @return the invent_count
	 */
	public int getInvent_count() {
		return invent_count;
	}

	/**
	 * @param invent_count
	 *            the invent_count to set
	 */
	public void setInvent_count(int invent_count) {
		this.invent_count = invent_count;
	}

	/**
	 * @return the practical_count
	 */
	public int getPractical_count() {
		return practical_count;
	}

	/**
	 * @param practical_count
	 *            the practical_count to set
	 */
	public void setPractical_count(int practical_count) {
		this.practical_count = practical_count;
	}

	/**
	 * @return the profile_count
	 */
	public int getProfile_count() {
		return profile_count;
	}

	/**
	 * @param profile_count
	 *            the profile_count to set
	 */
	public void setProfile_count(int profile_count) {
		this.profile_count = profile_count;
	}

	/**
	 * @return the others_count
	 */
	public int getOthers_count() {
		return others_count;
	}

	/**
	 * @param others_count
	 *            the others_count to set
	 */
	public void setOthers_count(int others_count) {
		this.others_count = others_count;
	}

	/**
	 * @return the type
	 */
	public int getType() {
		return type;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(int type) {
		this.type = type;
	}

	/**
	 * @return the year
	 */
	public String getYear() {
		return year;
	}

	/**
	 * @param year
	 *            the year to set
	 */
	public void setYear(String year) {
		this.year = year;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		super.setContentType(super.JSON);
		Enterprise_Patent ep = new Enterprise_Patent();
		ep.setEditable(1);
		ep.setEnterprise_id(dataReportM_InnovateBaseDao.getEnterpriseBaseId(userId));
		ep.setInvent_count(invent_count);
		ep.setOthers_count(others_count);
		ep.setPatent_check_pass(3);
//		ep.setPatent_id(1);
		ep.setPatent_is_new(0);
		ep.setPatent_type(type);
		ep.setPatent_year(year);
		ep.setPractical_count(practical_count);
		ep.setProfile_count(profile_count);
		ep.setResearch_count(research_count);
		ep.setThousand_count(thousand_count);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("patent_year", year);map.put("uid", userId);map.put("patent_type", type);
		if(dataReportM_InnovateBaseDao.isNewEnterprise_PatentExist(map)){
			super.outPrint("already");
			return "json";
		}
		if (dataReportM_InnovateBaseDao.insertNewEnterprise_PatentData(ep)) {
			super.outPrint("ok");
		} else {
			super.outPrint("fail");
		}
		return "json";
	}

}
